{$R-}

(*
	flash -- a sample HyperCard external command

	To compile and link this file using Macintosh Programmer's Workshop,

	pascal -w Flash.p
	pascal -w XCmdUtil.p
	asm -w XCmdUtil.a
	link -m ENTRYPOINT -o HyperCommands -rt XCMD=0 -sn Main=Flash Flash.p.o ¶
	  XCmdUtil.p.o XCmdUtil.a.o "{MPW}"Libraries:interface.o
	
*)

{$S Flash } 	{ Segment name must be the same as the command name. }

UNIT DummyUnit;

INTERFACE

USES MemTypes, QuickDraw, HyperXCmd, XCmdUtil;

PROCEDURE EntryPoint(paramPtr: XCmdPtr);
	
IMPLEMENTATION

PROCEDURE Flash(paramPtr: XCmdPtr); 							FORWARD;

  PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  BEGIN
    Flash(paramPtr);
  END;

  PROCEDURE Flash(paramPtr: XCmdPtr);
  VAR flashCount: LongInt;	
      i: INTEGER;
	  port: GrafPtr;
	  str: Str255;
	  
	PROCEDURE Fail(errMsg: Str255); { set theResult and quit }
	BEGIN
	  paramPtr^.returnValue := PasToZero(errMsg);
	  EXIT(Flash);
	END;

  BEGIN
	IF paramPtr^.paramCount <> 1 THEN Fail('parameter count is not 1');
	
	ZeroToPas(paramPtr^.params[1]^,str);	{ first param is flash count }
	flashCount := StrToNum(str);
	
	IF ODD(flashCount) THEN Fail('can''t flash an odd number of times');
	
	GetPort(port);
	FOR i := 1 TO flashCount DO 
	  BEGIN
		InvertRect(port^.portRect);
		InvertRect(port^.portRect);
	  END;
  END;


END.



